package com.zq.solution.listnode;

import java.util.Scanner;

/**
 * @ClassName CycleList
 * @Description
 * @Author ZQ
 * @Date 2020/10/9 15:07
 * @Version 1.0
 */
public class CycleList {
    public boolean hasCycle(ListNode<Integer> head){
        if (head == null || head.next == null)  return false;
        ListNode<Integer> fast = head.next;
        ListNode<Integer> slow = head;
        while (fast != slow){
            if(fast == null || fast.next == null)   return false;
            fast = fast.next.next;
            slow = slow.next;
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println("请输入链表长度：");
        Scanner sc = new Scanner(System.in);
        int size = sc.nextInt();
        if(size < 1){
            System.out.println("链表长度不能小于1，请重新输入:");
            size = sc.nextInt();
        }
        for (int i = 0; i < size; i++){

        }

    }
}
